<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateAddressesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('addresses', function (Blueprint $table) {
            $table->id();
            $table->integer('user_id')->unsigned()->comment('用户id');
            $table->string('accepter_name')->default('')->comment('收货人名字');
            $table->string('accepter_phone')->default('')->comment('收货人手机');
            $table->string('province_name')->default('')->comment('收货地址省');
            $table->string('city_name')->default('')->comment('收货地址市');
            $table->string('district_name')->default('')->comment('区县名字');
            $table->string('detail_address')->default('')->comment('详细地址');
            $table->integer('national_code')->unsigned()->comment('收货地址的国家码');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `addresses` comment '用户收货地址'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('addresses');
    }
}
